import 'package:guochaoapp/model/freight_entity.dart';

freightEntityFromJson(FreightEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new FreightData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> freightEntityToJson(FreightEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

freightDataFromJson(FreightData data, Map<String, dynamic> json) {
	if (json['distance'] != null) {
		data.distance = json['distance'] is String
				? int.tryParse(json['distance'])
				: json['distance'].toInt();
	}
	if (json['freightTotal'] != null) {
		data.freightTotal = json['freightTotal'] is String
				? double.tryParse(json['freightTotal'])
				: json['freightTotal'].toDouble();
	}
	if (json['addrId'] != null) {
		data.addrId = json['addrId'] is String
				? int.tryParse(json['addrId'])
				: json['addrId'].toInt();
	}
	if (json['receiverAddr'] != null) {
		data.receiverAddr = json['receiverAddr'].toString();
	}
	if (json['receiverName'] != null) {
		data.receiverName = json['receiverName'].toString();
	}
	if (json['receiverPhone'] != null) {
		data.receiverPhone = json['receiverPhone'].toString();
	}
	return data;
}

Map<String, dynamic> freightDataToJson(FreightData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['distance'] = entity.distance;
	data['freightTotal'] = entity.freightTotal;
	data['addrId'] = entity.addrId;
	data['receiverAddr'] = entity.receiverAddr;
	data['receiverName'] = entity.receiverName;
	data['receiverPhone'] = entity.receiverPhone;
	return data;
}